package inputjadwal.entity.service.impl;



import inputjadwal.entity.service.InputJadwalService;
import inputjadwal.entity.Dosen;
//import inputjadwal.entity.Jadwal;
import inputjadwal.entity.Pelajar;
import inputjadwal.entity.Pelajaran;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("appService")
@Transactional(readOnly=true)
public class InputJadwalImpl implements InputJadwalService {

    @Autowired private SessionFactory sessionFactory;

    
    //interface tabel t_dosen
    @Transactional(readOnly=false)
    @Override
    public void saveDosen(Dosen dosen) {
        sessionFactory.getCurrentSession().saveOrUpdate(dosen);
    }
    
    @Override
    public List<Dosen> findAllDosen() {
        return sessionFactory.getCurrentSession().createQuery("from Dosen").list();
    }

    @Transactional(readOnly=false)
    @Override
    public void deleteDosen(Dosen dosen) {
        sessionFactory.getCurrentSession().delete(dosen);
    }
    
    

    //interface tabel t_pelajar
    @Transactional(readOnly=false)
    @Override
    public void savePelajar(Pelajar pelajar) {
        sessionFactory.getCurrentSession().saveOrUpdate(pelajar);
    }
    
    @Override
    public List<Pelajar> findAllPelajar() {
        return sessionFactory.getCurrentSession().createQuery("from Pelajar").list();
    }  

    @Transactional(readOnly=false)
    @Override
    public void deletePelajar(Pelajar pelajar) {
        sessionFactory.getCurrentSession().delete(pelajar);
    }
    
    
    
    //interface tabel t_pelajaran

    @Transactional(readOnly=false)
    @Override
    public void savePelajaran(Pelajaran pelajaran) {
        sessionFactory.getCurrentSession().saveOrUpdate(pelajaran);
    }
    
    @Override
    public List<Pelajaran> findAllPelajaran() {
        return sessionFactory.getCurrentSession().createQuery("from Pelajaran").list();
    } 

    @Transactional(readOnly=false)
    @Override
    public void deletePelajaran(Pelajaran pelajaran) {
        sessionFactory.getCurrentSession().delete(pelajaran);
    }

    
    //interface tabel jadwal
//    @Override
//    public void viewJadwal(Jadwal jadwal) {
//        sessionFactory.getCurrentSession().createQuery("from Jadwal");
//    }
//
//    @Transactional(readOnly=false)
//    @Override
//    public void deleteJadwal(Jadwal jadwal) {
//        sessionFactory.getCurrentSession().delete(jadwal);
//    }   
   
    
}